import searchBox from "@/components/search-box"
export default {
    name: 'search',
    components: { searchBox },
    // 接收父页面传过来的属性
    props: {},
    // 页面数据绑定
    data() {
        return {
            // 搜索框下拉菜单数据
            menuData: [
                {
                    icon:'el-icon-time',
                    label:'最近搜索',
                    data:[]   
                },
                {
                    icon:'el-icon-collection',
                    label:'热门搜索',
                    type:'btn',
                    data:[]   
                },
            ],
            searchData: [],
        }
    },
    computed: {},
    methods: {
        /*
        * 构造数据
        */
        init() {
            for (let i = 0; i < 7; i++) {
                this.menuData[0].data.push({
                    value: '维权事件维权事件',
                })
                this.menuData[1].data.push({
                    value: '维权事件',
                })
            }
        },

        /*
        * 搜索
        */
        handleSearch(res) {
            console.log(res)
            this.$router.push({ name: 'search-details', params: { word: res } })
        },

        /*
        * 选中搜索栏
        */
        handleSelect(res) {
            this.handleSearch(res)
        },

        /*
         * 输入框变化
         */
        handleChange(value){
            this.searchData = []
            for (let i = 0; i < 6; i++) {
                this.searchData.push({
                    value: '搜索了'+value,
                })
            }
        }
    },
    created() { 
        this.init()
    },
    mounted() { }
}